﻿using System;
using System.IO;
using System.Linq;
using System.ServiceModel.Channels;
using System.Xml;

namespace SilverlightRestServices.Channels
{
    public class BinaryBodyWriter : BodyWriter
    {
        private Byte[] m_Buffer;

        public BinaryBodyWriter(Byte[] buffer)
            : base(true)
        {
            this.m_Buffer = buffer;
        }

        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            writer.WriteChars(this.m_Buffer.Cast<Char>().ToArray(), 0, this.m_Buffer.Length);
        }
    }
}
